import {createStore, mapState} from 'vuex'
import user from "@/store/user";
import axios from "axios";
import flag from "semantic-ui-vue/src/elements/Flag/Flag";

export default createStore({   //数据的管理，全局需要用的数据，多个组件都需要用的数据
  //设置全局数据的地方
  state: {
    count: 0,
    dzList: [],
    index: 7,
    o1: '',
    o2: '',
    o3: '',
    o4: '',
    o5: '',
    ao1: '',
    ao2: '',
    ao3: '',
    blogId: 1,
    commentContent: '',
    email: '',
    nickname: '',
    activeTypeId: 1,
    activeTagId: 1,
    edit: 0,
    typeSuccess: false,
    tagSuccess: false,
    username: '',
    password: ''

    //  浅红色   rgb(255, 246, 246)
    //
  },
  created() {

  },
  getters: {
    totalPrice:function (state){
      return state.count*100;
    }
  },
  computed:{
    // this.$store.d
    // ...mapState({ list: state=>state.scope.list})
  },
  //修改状态的方法
  mutations: {
    setUsernameColor:function (state){
      state.username = 'background-color: rgb(255, 246, 246)';
    },
    clearUsernameColor:function (state){
      state.username = '';
    },
    setPasswordColor:function (state){
      state.password = 'background-color: rgb(255, 246, 246)';
    },
    clearPasswordColor:function (state){
      state.password = '';
    },
    setContentColor:function (state){
      state.commentContent = 'background-color: rgb(255, 246, 246)';
    },
    setEmail:function (state){
      state.email = 'background-color: rgb(255, 246, 246)';
    },
    setNickname:function (state){
      state.nickname = 'background-color: rgb(255, 246, 246)';
    },

    clearContentColor:function (state){
      state.commentContent = '';
    },
    clearEmail:function (state){
      state.email = '';
    },
    clearNickname:function (state){
      state.nickname = '';
    },

    setCount:function (state){
      state.count++;
    },
    setO1:function(state) {
      state.o1 = '#00B5AD';
      state.o2 = '';
      state.o3 = '';
      state.o4 = '';
      state.o5 = '';
    },
    setO2:function(state) {
      state.o1 = '';
      state.o2 = '#00B5AD';
      state.o3 = '';
      state.o4 = '';
      state.o5 = '';
    },
    setO3:function(state) {
      state.o1 = '';
      state.o2 = '';
      state.o3 = '#00B5AD';
      state.o4 = '';
      state.o5 = '';
    },
    setO4:function(state) {
      state.o1 = '';
      state.o2 = '';
      state.o3 = '';
      state.o4 = '#00B5AD';
      state.o5 = '';
    },
    setO5:function(state) {
      state.o1 = '';
      state.o2 = '';
      state.o3 = '';
      state.o4 = '';
      state.o5 = '#00B5AD';
    },
    setAo1:function(state) {
      state.ao1 = '#00B5AD';
      state.ao2 = '';
      state.ao3 = '';
    },
    setAo2:function(state) {
      state.ao1 = '';
      state.ao2 = '#00B5AD';
      state.ao3 = '';
    },
    setAo3:function(state) {
      state.ao1 = '';
      state.ao2 = '';
      state.ao3 = '#00B5AD';
    },
    changeIndex:function (state,n){
      // alert(23);
      // alert(n);
      state.index = n;
    },
    setBlogId:function (state,n){
      state.blogId = n;
    },
    setActiveTypeId:function (state, typeId){
      state.activeTypeId = typeId;
    },
    setActiveTagId:function (state, tagId){
      state.activeTagId = tagId;
    },
    clearEdit:function (state){
      state.edit = 0;
    },
    setEdit:function (state){
      state.edit = 1;
    },
    setTypeSuccess:function (state){
      state.typeSuccess = true;
    },
    clearTypeSuccess:function (state){
      state.typeSuccess = false;
    },
    setTagSuccess:function (state){
      state.tagSuccess = true;
    },
    clearTagSuccess:function (state){
      state.tagSuccess = false;
    },
    data_teamA(state, x) {
      sessionStorage.setItem('teamA', JSON.stringify(x));
      state.teamA = x;
      // state.teamA = x
    }
  },
  //异步请求写在这里
  actions: {

    getDz:function (){

    },
    getColor:function (index){
      alert(index);
      if (this.state.index === index){
        return "background-color: #2e383c";
      }
    }

  },
  modules: {
    user
  }
})
